/**
 * Created by Administrator on 2017/5/25 0025.
 */
$(function(){
    if($.cookie("myloginName")!=undefined){
        var oUser = JSON.parse($.cookie("myloginName"));
        console.log(oUser);
        $("#txt").val(oUser.tel);
        $("#pwd").val(oUser.pwd);
    }
    $("#btn_login").on("click",function(){

        $.ajax({
            url:"./../php/login.php",
            type:"post",
            data:{"userTel":$("#txt").val(),"userPwd":$("#pwd").val()},
            success:function(result){
                var obj = JSON.parse(result);
                console.log(obj);
                var user = $("#txt").val();
                var pwd = $("#pwd").val();
                var json = {"tel":user,"pwd":pwd,"data": obj.data};
                var userdata = JSON.stringify(json);

                if(obj.status == 1){
                   if($("#cbx").prop("checked") == true){
                       $.cookie("myloginName",userdata,{path:"/",expires:10});
                   }else{
                       $.cookie("myloginName",userdata,{path:"/"});
                   }

                     window.location.href="/shanmao/index/index.html";

                }else if(obj.status == 0){
                    alert(obj.msg);
                }else{
                    alert("请输入您的登录信息")
                }
            }
        })
    })
})